package com.flextribe.display
{
	import com.flextribe.events.TribeGraphicsEvent;
	
	import flash.display.BitmapData;
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.geom.Matrix;

	/**
	 *  Dispatched when the graphics object changes.
	 *
	 *  @eventType com.flextribe.events.TribeGraphicsEvent.GRAPHICS_CHANGE
	 */
	[Event(name="graphicsChange", type="com.flextribe.events.TribeGraphicsEvent")]

	public class TribeGraphics extends Sprite
	{	
		private var _graphics:Graphics;
		public function TribeGraphics(){
			_graphics = this.graphics;
		}
		public function beginBitmapFill(bitmap:BitmapData, matrix:Matrix=null, repeat:Boolean=true, smooth:Boolean=false):void{
			_graphics.beginBitmapFill(bitmap, matrix, repeat, smooth);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function beginFill(color:uint, alpha:Number=1):void{
			_graphics.beginFill(color, alpha);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function beginGradientFill(type:String, colors:Array, alphas:Array, ratios:Array, matrix:Matrix, spreadMethod:String="pad", interpolationMethod:String="rgb", focalPointRation:Number=0):void{
			_graphics.beginGradientFill(type, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRation);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function clear():void{
			_graphics.clear();
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function curveTo(controlX:Number, controlY:Number, anchorX:Number, anchorY:Number):void{
			_graphics.curveTo(controlX, controlY, anchorX, anchorY);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function drawCircle(x:Number, y:Number, radius:Number):void{
			_graphics.drawCircle(x, y, radius);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function drawEllipse(x:Number, y:Number, width:Number, height:Number):void{
			_graphics.drawEllipse(x, y, width, height);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function drawRect(x:Number, y:Number, width:Number, height:Number):void{
			_graphics.drawRect(x, y, width, height);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function drawRoundRect(x:Number, y:Number, width:Number, height:Number, ellipseWidth:Number, ellipseHeight:Number=NaN):void{
			_graphics.drawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function drawRoundRectComplex(x:Number, y:Number, width:Number, height:Number, topLeftRadius:Number, topRightRadius:Number, bottomLeftRadius:Number, bottomRightRadius:Number):void{
			_graphics.drawRoundRectComplex(x, y, width, height, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function endFill():void{
			_graphics.endFill();
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function lineGradientStyle(type:String, colors:Array, alphas:Array, ratios:Array, matrix:Matrix=null, spreadMethod:String="pad", interpolationMethod:String="rgb", focalPointRation:Number=0):void{
			_graphics.lineGradientStyle(type, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRation);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function lineStyle(thickness:Number=NaN, color:uint=0, alpha:Number=1, pixelHinting:Boolean=false, scaleMode:String="normal", caps:String=null, joints:String=null, miterLimit:Number=3):void{
			_graphics.lineStyle(thickness, color, alpha, pixelHinting, scaleMode, caps, joints, miterLimit);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function lineTo(x:Number, y:Number):void{
			_graphics.lineTo(x, y);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		public function moveTo(x:Number, y:Number):void{
			_graphics.moveTo(x, y);
			this.dispatchEvent(new TribeGraphicsEvent(TribeGraphicsEvent.GRAPHICS_CHANGE));
		}
		
	}
}